package test.myJdkProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.lang.reflect.Proxy;

public class $Proxy0 extends Proxy implements Interface{

    public $Proxy0(InvocationHandler h) {
        super(h);
    }
    @Override
    public int introduce() {

        try {
            Parameter[] parameters = introduce.getParameters();
            Object result = h.invoke(this,introduce, parameters);
            return (int)result;
        } catch (RuntimeException | Error e) {
            throw e;
        }catch (Throwable e){
            throw new RuntimeException(e);
        }
    }

    @Override
    public int study() {
        try {
            Parameter[] parameters = study.getParameters();
            Object result = h.invoke(this, study, parameters);
            return (int)result;
        } catch (RuntimeException | Error e) {
            throw e;
        }catch (Throwable e){
            throw new RuntimeException(e);
        }
    }
    static Method introduce;
    static Method study;
    //不能抛异常
    static {
        try {
            introduce = Interface.class.getMethod("introduce");
            study = Interface.class.getMethod("study");
        } catch (NoSuchMethodException e) {
           throw new NoSuchMethodError(e.getMessage());
        }
    }

}
